public class 树的深度 {
    

    public static void main(String[] args) {
        
        TN root = new TN(5);
        root.left = new TN(4);
        root.right = new TN(8);
        root.left.left = new TN(11);
        root.left.right = new TN(13);
        root.right.left = new TN(4);
        root.right.right = new TN(7);
        root.left.right.left = new TN(2);
        root.left.right.right = new TN(9);

        int treeDep = treeDep(root);

        System.out.println(""+treeDep);

    }

    private static int treeDep(TN root){

        if(null == root) return 0;

        return Math.max(treeDep(root.left), treeDep(root.right)) + 1;
    }

    private static class TN {

        int val;
        TN left;
        TN right;

        public TN(int val){

            this.val = val;
        }

    }
}
